package com.itqf.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.itqf.dto.TableData;
import com.itqf.dto.TableParam;
import com.itqf.entity.ScheduleJob;
import com.itqf.service.ScheduleJobService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/11/27
 * @Time: 下午3:12
 */
@RestController
public class ScheduleJobController {

    @Resource
    private ScheduleJobService scheduleJobService;

    @RequestMapping("/schedule/job/save")
    public R  saveSchedule(@RequestBody ScheduleJob scheduleJob){

        return  scheduleJobService.saveSchedule(scheduleJob);
    }

    @RequestMapping("/schedule/job/update")
    public R  updateSchedule(@RequestBody ScheduleJob scheduleJob){

        return  scheduleJobService.updateSchedule(scheduleJob);
    }

    @RequestMapping("/schedule/job/del")
    public R  deleteSchedule(@RequestBody List<Long> ids){

        return  scheduleJobService.deleteSchedule(ids);
    }
    @RequestMapping("/schedule/job/resume")
    public R  resumeSchedule(@RequestBody List<Long> ids){

        return  scheduleJobService.resumeSchedule(ids);
    }

    @RequestMapping("/schedule/job/pause")
    public R  pauseSchedule(@RequestBody List<Long> ids){

        return  scheduleJobService.pauseSchedule(ids);
    }

    @RequestMapping("/schedule/job/run")
    public R  runOnceSchedule(@RequestBody List<Long> ids){

        return  scheduleJobService.runOnceSchedule(ids);
    }


    @RequestMapping("/schedule/job/info/{jobId}")
    public  R  scheduleInfo(@PathVariable long jobId){

        return  scheduleJobService.findScheduleById(jobId);
    }

    @RequestMapping("/schedule/job/list")
    //?limit=10&offset=0
    public TableData scheduleList(TableParam param){
        return  scheduleJobService.scheduleList(param);
    }


}
